package com.cyc.lock;

/**
 * synchronized  可重入锁
 */
public class Demo01 {

    public static void main(String[] args) {
        Phone phone = new Phone();
        new Thread(()->{
            phone.call();
        },"A").start();

        new Thread(()->{
            phone.call();
        },"B").start();

    }



}
class Phone{

    //当send()执行完后才解锁
    public synchronized void call(){
        System.out.println(Thread.currentThread().getName()+"call()");
        send();
    }

    public synchronized void send(){
        System.out.println(Thread.currentThread().getName()+"send()");
    }
}
